Socket
Socket
Sign inDemoInstall

mri

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mri

Quickly scan for CLI flags and arguments


Version published
Maintainers
1
Created

What is mri?

The mri npm package is a lightweight option parsing library. It allows for easy parsing of command-line options, providing a simple API to access command-line arguments in a structured way. It's designed for performance and simplicity, making it a great choice for projects that require basic yet efficient argument parsing without the overhead of more complex libraries.

What are mri's main functionalities?

Basic Option Parsing

This code demonstrates how to parse command-line arguments using mri. It slices the process.argv array to ignore the first two entries (node path and script path), then parses the remaining arguments into an options object.

const mri = require('mri');
const args = process.argv.slice(2);
const options = mri(args);
console.log(options);

Specifying Option Types

This example shows how to specify the types of options (boolean, string) and aliases for them. This helps in parsing the command-line arguments more accurately according to the expected types and aliases.

const mri = require('mri');
const args = process.argv.slice(2);
const cliOptions = {
  boolean: ['help', 'version'],
  string: ['output'],
  alias: { h: 'help', v: 'version', o: 'output' }
};
const options = mri(args, cliOptions);
console.log(options);

Other packages similar to mri

Keywords

FAQs

Package last updated on 12 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc